
	
/*
 * 自动计算表单数据
 */
function calFormItem() {
	
	var domForm = $('#' + window.formObj.c.id_form);
	var authDate = domForm.find('input[name="authDate"]').val(); // 授权日期
	var validDays = parseFloat(domForm.find('input[name="validDays"]').val()); // 有效天数

	if(authDate
			&& (validDays || validDays == 0)) {
		// 到期日期 = 授权日期 + 有效天数
		var authExpireDate = new Date(Date.parse(authDate));
		
		authExpireDate.setDate(authExpireDate.getDate() + validDays);
		domForm.find('input[name="authExpireDate"]').val(formatDate(authExpireDate));
	}
}

function formatDate(date) {
	var year = date.getFullYear();
	var month = ('0' + (date.getMonth() + 1)).slice(-2);
	var day = ('0' + date.getDate()).slice(-2);
	var hours = ('0' + date.getHours()).slice(-2);
	var minutes = ('0' + date.getMinutes()).slice(-2);
	var seconds = ('0' + date.getSeconds()).slice(-2);
	
	return year + '-' + month + '-' + day;
}